package com.fivefu.core.camera.controller;

import com.fivefu.base.web.controller.BaseController;
import com.fivefu.base.web.vo.ResultInfo;
import com.fivefu.core.camera.services.CameraTreeService;
import com.fivefu.core.data.vo.TreeVo;
import com.fivefu.core.hik.services.CameraService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(tags = "测试1")
@RestController
@RequestMapping("/test3")
public class Test3Controller extends BaseController {

    private Logger logger = LoggerFactory.getLogger(Test3Controller.class);

    @Autowired
    private CameraTreeService cameraTreeService;

    @ApiOperation(value = "测试1",httpMethod = "POST",response = ResultInfo.class,notes = "测试1")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "查询类型(list,tree)",paramType = "query",required = true, dataType = "String"),
    })
    @RequestMapping(path = "/test",method = RequestMethod.POST)
    public ResultInfo test(String type) {
        try {
            List<TreeVo> list = cameraTreeService.getMonitorRegionTree(type);
            return ResultInfo.renderSuccess(list);
        }catch (Exception e){
            logger.error(e.getMessage(),e);
        }
        return ResultInfo.renderError("失败");
    }

    @ApiOperation(value = "测试2",httpMethod = "POST",response = ResultInfo.class,notes = "测试2")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "查询类型(list,tree)",paramType = "query",required = true, dataType = "String"),
            @ApiImplicitParam(name = "labelId",value = "标签编号",paramType = "query",required = true, dataType = "Long"),
    })
    @RequestMapping(path = "/test2",method = RequestMethod.POST)
    public ResultInfo test2(String type, Long labelId) {
        try {
            List<TreeVo> list = cameraTreeService.getAddMonitorRegionTreeByLabelId(type, labelId);
            return ResultInfo.renderSuccess(list);
        }catch (Exception e){
            logger.error(e.getMessage(),e);
        }
        return ResultInfo.renderError("失败");
    }

    @ApiOperation(value = "测试3",httpMethod = "POST",response = ResultInfo.class,notes = "测试3")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "查询类型(list,tree)",paramType = "query",required = true, dataType = "String"),
            @ApiImplicitParam(name = "sceneId",value = "场景编号",paramType = "query",required = true, dataType = "Long"),
    })
    @RequestMapping(path = "/test3",method = RequestMethod.POST)
    public ResultInfo test3(String type, Long sceneId) {
        try {
            List<TreeVo> list = cameraTreeService.getAddMonitorRegionTreeBySceneId(type, sceneId);
            return ResultInfo.renderSuccess(list);
        }catch (Exception e){
            logger.error(e.getMessage(),e);
        }
        return ResultInfo.renderError("失败");
    }

}
